
package com.eworking.eim.message.body;

import java.io.File;

import com.eworking.eim.util.EIMLog;

import android.os.Parcel;
import android.os.Parcelable;

public class ImageMessageBody extends FileMessageBody {
    
    /** 缩略图地址 */
    public String thumbnailUrl;
    
    /** 缩略图 */
    public String thumbnailSecret = null;
    
    /** 是否发送原始的图片 */
    public boolean sendOriginalImage;
    
    public static final Parcelable.Creator<ImageMessageBody> CREATOR = new Parcelable.Creator<ImageMessageBody>() {
        
        public ImageMessageBody createFromParcel(Parcel parcel) {
            return new ImageMessageBody(parcel);
        }
        
        public ImageMessageBody[] newArray(int size) {
            return new ImageMessageBody[size];
        }
        
    };
    
    public ImageMessageBody(File file) throws IllegalArgumentException {
        if (!(file.exists()))
            throw new IllegalArgumentException("image doesn't exists:" + file.getAbsolutePath());
        this.localUrl = file.getAbsolutePath();
        this.fileName = file.getName();
        EIMLog.d("imagemsg", "create image message body for:" + file.getAbsolutePath());
    }
    
    public ImageMessageBody(String fileName, String remoteUrl, String thumbnailUrl) {
        this.fileName = fileName;
        this.remoteUrl = remoteUrl;
        this.thumbnailUrl = thumbnailUrl;
    }
    
    public String getThumbnailUrl() {
        return this.thumbnailUrl;
    }
    
    public void setThumbnailUrl(String paramString) {
        this.thumbnailUrl = paramString;
    }
    
    public String toString() {
        return "image:" + this.fileName + ",localurl:" + this.localUrl + ",remoteurl:" + this.remoteUrl + ",thumbnial:"
            + this.thumbnailUrl;
    }
    
    public int describeContents() {
        return 0;
    }
    
    public void writeToParcel(Parcel parcel, int paramInt) {
        parcel.writeString(this.fileName);
        parcel.writeString(this.localUrl);
        parcel.writeString(this.remoteUrl);
        parcel.writeString(this.thumbnailUrl);
    }
    
    private ImageMessageBody(Parcel parcel) {
        this.fileName = parcel.readString();
        this.localUrl = parcel.readString();
        this.remoteUrl = parcel.readString();
        this.thumbnailUrl = parcel.readString();
    }
    
    public void setThumbnailSecret(String paramString) {
        this.thumbnailSecret = paramString;
    }
    
    public String getThumbnailSecret() {
        return this.thumbnailSecret;
    }
    
    public void setSendOriginalImage(boolean paramBoolean) {
        this.sendOriginalImage = paramBoolean;
    }
    
    public boolean isSendOriginalImage() {
        return this.sendOriginalImage;
    }
    
}
